package cn.sofwin.spring.db.config;

import cn.sofwin.spring.db.entity.User;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

/**
 *  配置类
 * @author GN
 * @email it_everywhere@163.com
 * @version 1.0
 */
@Configuration
@ComponentScan("cn.sofwin")
@PropertySource("classpath:app.properties")
public class AppConfig {
    @Bean
    public DataSource dataSource(){
        DruidDataSource ds = new DruidDataSource();
        ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
        ds.setUsername("root");
        ds.setUrl("jdbc:mysql://localhost:3306/spring_demo?serverTimezone=UTC");
        ds.setPassword("123456");
        return ds;
    }

    @Bean
    public JdbcTemplate getjdbc(){
        String sql="";
        JdbcTemplate jdbcTemplate = new JdbcTemplate();
        return jdbcTemplate;
    }

}
